<?php
class ActiveBarWidget extends CWidget
{
    public function init()
    {
        parent::init();
    }
    public function run()
    { 
        $cart_count = 0;
        $cart_goods_count = 0;
        $is_shop_user = 0;
        if (!Yii::app()->user->isGuest) {
            $filter['user_id'] = Yii::app()->user->getId();
            $data = Cart::model()->CountByAttr($filter);
            if (!empty($data)) {
                $cart_goods_count = $data['goods_count'];//只计算商品的种类数量
                $cart_count =  $data['total_count'];//包含商品的 购物车里的数量
            }

            $user_info = User::model()->getDetail(Yii::app()->user->getId());
            if (!empty($user_info) && !empty($user_info['type'])) {
                if (in_array(6,$user_info['type'])) {
                    $is_shop_user =1;
                }
            }
        }
        $this->render('activebar',compact('cart_count','cart_goods_count','is_shop_user'));
    }
}
?>
